package com.cxhc.system.service.app.impl;

import java.util.List;
import com.cxhc.common.utils.StringUtils;
import com.cxhc.system.domain.app.RpRevHandling;
import com.cxhc.system.mapper.app.RpRevHandlingMapper;
import com.cxhc.system.service.app.IRpRevHandlingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 接触警Service业务层处理
 * 
 * @author Dhq
 * @date 2024-08-13
 */
@Service
public class RpRevHandlingServiceImpl implements IRpRevHandlingService
{
    @Autowired
    private RpRevHandlingMapper rpRevHandlingMapper;

    /**
     * 查询接触警
     * 
     * @param id 接触警主键
     * @return 接触警
     */
    @Override
    public RpRevHandling selectRpRevHandlingById(Long id)
    {
        RpRevHandling rpRevHandling = rpRevHandlingMapper.selectRpRevHandlingById(id);
        if (!StringUtils.isEmpty(rpRevHandling.getPhoto())){
            rpRevHandling.setPhoto(rpRevHandling.getPhoto().replaceAll("http://img.wq-info.com","https://huanchuang-imgs.wq-info.com"));
        }
        if (!StringUtils.isEmpty(rpRevHandling.getResultPhoto())){
            rpRevHandling.setResultPhoto(rpRevHandling.getResultPhoto().replaceAll("http://img.wq-info.com","https://huanchuang-imgs.wq-info.com"));
        }
        return rpRevHandling;
    }

    /**
     * 查询接触警列表
     * 
     * @param rpRevHandling 接触警
     * @return 接触警
     */
    @Override
    public List<RpRevHandling> selectRpRevHandlingList(RpRevHandling rpRevHandling)
    {

        List<RpRevHandling> rpRevHandlings = rpRevHandlingMapper.selectRpRevHandlingList(rpRevHandling);
        for (RpRevHandling revHandling : rpRevHandlings) {
            if (!StringUtils.isEmpty(revHandling.getPhoto())){
                revHandling.setPhoto(revHandling.getPhoto().replaceAll("http://img.wq-info.com","https://huanchuang-imgs.wq-info.com"));
            }
            if (!StringUtils.isEmpty(revHandling.getResultPhoto())){
                revHandling.setResultPhoto(revHandling.getResultPhoto().replaceAll("http://img.wq-info.com","https://huanchuang-imgs.wq-info.com"));
            }
        }
        return rpRevHandlings;
    }

    @Override
    public List<RpRevHandling> selectRpRevHandlingListForSerch(String name) {
        List<RpRevHandling> rpRevHandlings = rpRevHandlingMapper.selectForSyn();
        int i = rpRevHandlingMapper.batchInsertRpRevHandling(rpRevHandlings);
        return null;
    }

    /**
     * 新增接触警
     * 
     * @param rpRevHandling 接触警
     * @return 结果
     */
    @Override
    public int insertRpRevHandling(RpRevHandling rpRevHandling)
    {
        return rpRevHandlingMapper.insertRpRevHandling(rpRevHandling);
    }

    /**
     * 修改接触警
     * 
     * @param rpRevHandling 接触警
     * @return 结果
     */
    @Override
    public int updateRpRevHandling(RpRevHandling rpRevHandling)
    {
        return rpRevHandlingMapper.updateRpRevHandling(rpRevHandling);
    }

    /**
     * 批量删除接触警
     * 
     * @param ids 需要删除的接触警主键
     * @return 结果
     */
    @Override
    public int deleteRpRevHandlingByIds(Long[] ids)
    {
        return rpRevHandlingMapper.deleteRpRevHandlingByIds(ids);
    }

    /**
     * 删除接触警信息
     * 
     * @param id 接触警主键
     * @return 结果
     */
    @Override
    public int deleteRpRevHandlingById(Long id)
    {
        return rpRevHandlingMapper.deleteRpRevHandlingById(id);
    }
}
